{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<script>
    var editor;
    KindEditor.ready(function (K) {
        editor = K.create('textarea[name="content"],textarea[name="sale_protection"]', {
            uploadJson: '{url:/admin/upload_image}'
        });
    });
</script>
<div id="obj_form" class="form2 tab" style="margin-left: -50px;margin-top: 40px;">

    <!-- 基本信息 start -->
    <form action="{url:/customer/up_down_active}" id="up_down" class=" " method="post" callback="up_down"
          enctype="multipart/form-data">
        <div>
            <!--<dl class="lineD">-->
            <!--<dt>-->
            <!--会员账号：-->
            <!--</dt>-->
            <!--<dd>-->
            <!--<input name="uname" id="uname" type="text" pattern="required" alt="请填写会员账号" value="{$customer[name]}" style="width:310px;" >-->
            <!--<label></label>-->
            <!--</dd>-->
            <!--</dl>-->
            <dl class="lineD">
                <dt>选择等级：</dt>
                <dd>
                    <select pattern="required" name="agent" id="agent" alt="请选择类别" style="width:320px;">
                        <option value="">请选择级别</option>
                        {query:name=grade}
                        <option value="{$item['id']}">{$item['name']}({$item['money']})</option>
                        {/query}
                    </select>
                    <label></label>
                </dd>
            </dl>
            <dl>
                <dt class="label"></dt>
                <dd>
                    <select id="province" name="province">
                        <option value="">==省份/直辖市==</option>
                        {query:name=area where=parent_id eq 0}
                        <option value="{$item['id']}">{$item['name']}</option>
                        {/query}
                    </select>
                    <select id="city" name="city">
                        <option value="">==市==</option>
                    </select>
                    <select id="county" name="county">
                        <option value="">==县/区==</option>
                    </select>
                </dd>
            </dl>
        </div>
        <!-- tab 头 end -->
        <div style="margin-left:150px;margin-top:20px;">
            <input type="hidden" value="{$id}" name="id">
            <input type="submit" class="focus_button" value="提交">
            &nbsp;&nbsp;&nbsp;&nbsp;
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function () {
        $("#province").change(function () {
            var id = $(this).val();
//            alert(id);
            if (id == '') {
                $("#city").html("<option value=''>==市==</option>");
                $("#county").html("<option value=''>==县/区==</option>");
            }
            else {
                $.post("{url:/customer/transform}", {id: id}, function (data) {
                    $("#city").html("<option value=''>==市==</option>");
                    $("#county").html("<option value=''>==县/区==</option>");
                    $("#city").append(data);
                }, 'text');
            }

        });

        $("#city").change(function () {
            var id = $(this).val();
            if (id == '') {
                $("#county").html("<option value=''>==县/区==</option>");
            }
            else {
                $.post("{url:/customer/transform}", {id: id}, function (data) {
                    $("#county").html("<option value=''>==县/区==</option>");
                    $("#county").append(data);
                }, 'text');

            }

        })

    });
</script>
<script type="text/javascript">
    $(function () {
        $('#agent').val('{$group_id}').attr('selected', true);
//        $('#province').val('{$province}').attr('selected',true);
//        $('#city').val('{$city}').attr('selected',true);
//        $('#county').val('{$county}').attr('selected',true);
    });


    function up_down(e) {
        if (e == null) {
//            $(".focus_button").attr("disabled", true);
            var fields = $("#up_down").serializeArray();
//            console.log(fields);
            $.post("{url:/customer/up_down_active}", fields, function (data) {
//                console.log(data);
                if (data['status'] == 'success') {
                    art.dialog.tips("<p class='" + data['status'] + "'>" + data['msg'] + "</p>", 2);
                    setInterval(function () {
                        parent.location.reload();
                    }, 2000)
                } else {
                    art.dialog.tips("<p class='" + data['status'] + "'>" + data['msg'] + "</p>");
                }
                $("#balance-btn").attr("disabled", false);
            }, 'json');
        }
        return false;
    }
</script>
